﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Foxit.PDF;
using Foxit.PDF.IO;
using Foxit.PDF.PageElements;

namespace Sustainalytics.RiskRatings.Reporting.Charts
{
    class BulletChart : PageElement
    {
        public float Left { get; set; }
        public float Top { get; set; }
        public float Width { get; set; }
        public float Height { get; set; }
        public float Value1 { get; set; }
        public float Value2 { get; set; }
        public float MaxValueXAxis { get; set; }
        public float BarHeight { get; set; }

        private Group Elements()
        {
            var elements = new Group();
            float currentYOffset = Top + BarHeight / 2, dotSize = Width / MaxValueXAxis;
            elements.Add(new Line(Left, currentYOffset, Left + Value1 * dotSize, currentYOffset, BarHeight, new RgbColor(180, 213, 209)));
            elements.Add(new Line(Left, currentYOffset, Left + Value2 * dotSize, currentYOffset, BarHeight/2, RgbColor.Black));

            return elements;
        }

        public override void Draw(PageWriter writer)
        {
            var elements = Elements();

            writer.Write_q_(true);
            elements.Draw(writer);
            writer.Write_Q(true);
        }
    }
}
